/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package web.usuarios;

import Persistencia.*;
import controladores.*;
import dominio.TratamientoDomain;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Alith
 */
public class ControladorSubirVideo implements Controller{

    ControladorSesion controlador;
    Sesion obj;

    @Override
    public ModelAndView handleRequest(HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
        controlador = new ControladorSesion();
        Map<String, Object> myModel = new HashMap<String, Object>();
        if(hsr.getParameter("video") != null){
            System.out.println(hsr.getParameter("video"));
            controlador = new ControladorSesion();
            obj =controlador.encontrarSesion(hsr.getParameter("id_sesion"));            
            if(obj!=null){
                obj.setVideo(hsr.getParameter("video"));
                controlador.setSes(obj);
                controlador.modificarSesion();                
            }
            myModel.put("id_fisio", hsr.getParameter("id_fisio"));
            myModel.put("sesiones", controlador.encontrarMisSesiones(hsr.getParameter("id_fisio")));
            return new ModelAndView("administrarSesionesVideo", "model", myModel);
        }else{
            return new ModelAndView("administrarTratamientos", "model", myModel);
        }
    }

    public void setControladorSesion(ControladorSesion productManager) {
        this.controlador = productManager;
    }

    public ControladorSesion getControladorTratamiento() {
        return controlador;
    }
}
